//
//  RejectView.m
//  pa
//
//  Created by HaiJiao Chen on 12-8-22.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "RejectView.h"
#import "AppDelegate.h"
#import "MainObject.h"
#import "TicketList.h"
#import "FilePack.h"
#import "text_def.h"

@implementation RejectView
@synthesize name;
@synthesize reason;
@synthesize acceptView;

-(IBAction)cancel:(id)sender
{
    [self removeFromSuperview];
}
-(IBAction)save:(id)sender
{
    if ([name.text length] > 0 && [reason.text length] > 0)
    {
        NSMutableDictionary* c = [[AppDelegate sharedInstance].main.ticketsDataSource.memoryObject objectForKey:[NSString stringWithFormat:@"%lld", ticketID]];
        [c setValue:name.text forKey:REJECT_NAME];
        [c setValue:reason.text forKey:REJECT_REASON];
        [acceptView removeFromSuperview];
        [self removeFromSuperview];
    }
    else
    {
        UIAlertView* alert = [[UIAlertView alloc] initWithTitle:nil message:[FilePack getStringByID:STR_REJECT_ALERT] delegate:self cancelButtonTitle:[FilePack getStringByID:STR_OK] otherButtonTitles:nil];
        [alert show];
        [alert release];
    }
}

- (void)viewLoadFromNib:(NSNumber*)param
{
    ticketID = [param longLongValue];
    NSMutableDictionary* c = [[AppDelegate sharedInstance].main.ticketsDataSource.memoryObject objectForKey:[NSString stringWithFormat:@"%lld", ticketID]];
   
    name.text = [c valueForKey:REJECT_NAME];
    reason.text = [c valueForKey:REJECT_REASON];
}

@end
